#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <assert.h>

namespace zh 
{
	class string
	{
	public:
		string(const char* str = "");
		string(const string& s);
		const size_t& size() const;
		const char* c_str() const;
		char& operator[](const size_t& i);
		const char& operator[](const size_t& i) const;
		void resize(const size_t& n, const char& c = '\0');
		void reserve(const size_t& i);
		string& insert(const size_t& pos, const char& c);
		string& insert(const size_t& pos, const char* pc);
		string& erase(const size_t& pos, size_t len = npos);
		size_t find(const char& c, size_t pos = 0);
		size_t find(const char* pc, size_t pos = 0);
		string& push_back(const char& c);
		string& append(const char*& pc);
		string& operator+=(const char& c);
		string& operator+=(const char*& pc);
		string& operator=(string s);
		bool operator<(const string& s);
		bool operator==(const string& s);
		bool operator>(const string& s);
		bool operator<=(const string& s);
		bool operator>=(const string& s);
		bool operator!=(const string& s);
		void clear();
		~string();
	private:
		char* _str;
		size_t _size;
		size_t _capacity;

		static size_t npos;
	};

	std::ostream& operator<<(std::ostream& out, const string& s)
	{
		for (int i = 0;i < s.size();++i)
		{
			std::cout << s[i];
		}
		return out;
	}

	std::istream& operator>>(std::istream& in, string& s)
	{
		s.clear();
		char ch;
		while (in.get(ch) && ch != ' ')
		{
			s.push_back(ch);
		};
		return in;
	}
}